<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://xmlns.jcp.org/jsf/html">

    <h:body>

        <h:outputStylesheet library="css" name="stickerprints.css" />

        <ui:composition template="/resources/template/template.xhtml">
            <ui:define name="content">



                <h:form>


                    <p:panel header="Sample Collection" ></p:panel>
                    <h:panelGrid columns="5" >
                        <p:outputLabel value="Enter Bill ID" ></p:outputLabel>
                        <p:inputText value="#{patientInvestigationController.inputBillId}" ></p:inputText>
                        <p:commandButton value="Collect Sample &amp; Print Barcodes" ajax="false" action="#{patientInvestigationController.prepareSampleCollection()}" ></p:commandButton>
                        <p:spacer height="1" width="30" ></p:spacer>
                        <p:commandButton value="Sampling" ajax="false"  action="/lab/sample" actionListener="#{patientInvestigationController.toCollectSample()}"  ></p:commandButton>

                    </h:panelGrid>

                    <p:dataTable value="#{patientInvestigationController.patientSamples}" var="ps" >

                        <p:column headerText="Sample" >
                            <p:outputLabel value="#{ps.sample.name}" ></p:outputLabel>
                        </p:column>
                        <p:column headerText="Tube" >
                            <p:outputLabel value="#{ps.tube.name}" ></p:outputLabel>
                        </p:column>
                        <p:column headerText="Machine" >
                            <p:outputLabel value="#{ps.machine.name}" ></p:outputLabel>
                        </p:column>
                        <p:column headerText="Tests" >
                            #{patientInvestigationController.testComponantsForPatientSample(ps)}
                            <ui:repeat value="#{patientInvestigationController.testComponantsForPatientSample(ps)}" var="test" >
                                <p:outputLabel value="#{test}" ></p:outputLabel>
                            </ui:repeat>
                        </p:column>
                    </p:dataTable>



                    <p:commandButton value="Print" ajax="false"  >
                        <p:printer target="print" ></p:printer>
                    </p:commandButton>
                    <h:panelGroup id="print" >
                        <ui:repeat value="#{patientInvestigationController.patientSamples}" var="ps" >
                            <div style="page-break-after: always; width: 97vw;height: 97vh;border: none; margin: 0px;overflow: hidden; text-align: center; vertical-align: central" >
                                <table style="width:100%;height: " >
                                    <tr>
                                        <td>
                                            <h:outputLabel value="#{ps.bill.patient.person.nameWithTitle}"
                                                           style="font-size: 8px" ></h:outputLabel>

                                        </td>
                                        <td rowspan="3">

                                            <p:barcode cache="false" value="#{ps.idStr}" type="code128" width="130px" ></p:barcode>


                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <h:outputLabel value="ESR"
                                                           style="font-size: 8px" ></h:outputLabel>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <h:outputLabel value="Serum"
                                                           style="font-size: 8px" ></h:outputLabel>
                                        </td>
                                    </tr>
                                </table>




                            </div>
                        </ui:repeat>
                    </h:panelGroup>

                </h:form>


            </ui:define>


        </ui:composition>

    </h:body>
</html>
